﻿using UnityEngine;
using System.Collections;
using Mono.Data.Sqlite;

public class my_Data 
{
    public SqliteDataReader GetreaderById(string tableName, int id )
    {
        return Database.Instance.sql.ReadTable(
            tableName,
            new string[]{"*"},
            new string[]{"ID"},
            new string[]{"="},
            new string[]{"'"+id.ToString("G")+"'"});
    }
}

public class Item_data:my_Data
{
	public int ID;							//id
	public string name;						//名字
	public int icon_id;						//图标id
	public string note;						//说明
	public int type;						//类型

	public Item_data(int item_id)
    {
        SqliteDataReader reader = GetreaderById("item",item_id);
        // reader = Database.Instance.sql.ReadTable("item",
        //     new string[]{"ID","name","note","type"},
        //     new string[]{"ID"},
        //     new string[]{"="},
        //     new string[]{"'"+item_id.ToString("G")+"'"});
         while (reader.Read())
         {
            ID = reader.GetInt32(reader.GetOrdinal("ID"));
            name = reader.GetString(reader.GetOrdinal("name"));
            note = reader.GetString(reader.GetOrdinal("note"));
            type = reader.GetInt32(reader.GetOrdinal("type"));
         }
        reader.Close();
    }
}

public class Skill_data:my_Data
{
	public int ID;							//id
	public string name;						//名字
	public int icon_id;						//图标id
	public int type;						//类型
	public string note;						//说明
	public float attack_distance;			//攻击距离
	public float cd_time;					//冷却时间
	public bool auto_use;					//自动使用
	public int direct_dmg;					//直接伤害
	public int direct_treat;				//直接治疗
	public float factor_dmg;				//伤害系数
	public float factor_treat;				//治疗系数

	public Skill_data(int skill_id)
	{
        SqliteDataReader reader = GetreaderById("skill",skill_id);
         while (reader.Read())
         {
            ID = reader.GetInt32(reader.GetOrdinal("ID"));
            name = reader.GetString(reader.GetOrdinal("name"));
            note = reader.GetString(reader.GetOrdinal("note"));
            type = reader.GetInt32(reader.GetOrdinal("type"));
         }
        reader.Close();
	}
  
}

public class Monster_data:my_Data
{
	public int ID;
	public string name;
	public int model_id;
	public float radius;
	public float height;
	public float find_distance;
	public float hate_distance;
	public float track_distance;
	public float movespeed;
	public int level;
	public int health;
	public int health_now;
	public int hit;
	public int miss;
	public int hurt;
	public int armor;
	public int crit;

	public Monster_data(int monster_id)
    {
        SqliteDataReader reader = GetreaderById("monster",monster_id);
         while (reader.Read())
         {
            ID = reader.GetInt32(reader.GetOrdinal("ID"));
            name = reader.GetString(reader.GetOrdinal("name"));
            model_id = reader.GetInt32(reader.GetOrdinal("model_id"));
            radius = reader.GetFloat(reader.GetOrdinal("radius"));
            height = reader.GetFloat(reader.GetOrdinal("height"));
            find_distance = reader.GetFloat(reader.GetOrdinal("find_distance"));
            hate_distance = reader.GetFloat(reader.GetOrdinal("hate_distance"));
            track_distance = reader.GetFloat(reader.GetOrdinal("track_distance"));
            movespeed = reader.GetFloat(reader.GetOrdinal("movespeed"));
            level = reader.GetInt32(reader.GetOrdinal("level"));
            health = reader.GetInt32(reader.GetOrdinal("health"));
            health_now = reader.GetInt32(reader.GetOrdinal("health_now"));
            hit = reader.GetInt32(reader.GetOrdinal("hit"));
            miss = reader.GetInt32(reader.GetOrdinal("miss"));
            hurt = reader.GetInt32(reader.GetOrdinal("hurt"));
            armor = reader.GetInt32(reader.GetOrdinal("armor"));
            crit = reader.GetInt32(reader.GetOrdinal("crit"));
         }
        
        reader.Close();
    }
}

public class Brave_data:my_Data
{

	public int ID;						//id
	public string name;					//名字
	public string note;					//说明
	public int model_id;				//模型id
	public float radius;				//半径
	public float height;				//高度
	public float find_distance;			//发现距离
	public float hate_distance;			//仇恨距离
	public float track_distance;		//追击距离
	public float movespeed;				//移动速度
	public float level;					//等级
	public int skill_1;					//技能1id
	public int skill_2;					//技能2id
	public int health;					//血量
	public int health_now;				//当前血量
	public int vitality;				//体力
	public int vitality_now;			//当前体力
	public int hit;						//命中
	public int miss;					//闪避
	public int exp;						//经验
	public int hurt;					//攻击力
	public int armor;					//护甲值
	public int crit;					//暴击

	public Brave_data(int brave_id)
    {
        SqliteDataReader reader = GetreaderById("item",brave_id);
         while (reader.Read())
         {
            ID = reader.GetInt32(reader.GetOrdinal("ID"));
            name = reader.GetString(reader.GetOrdinal("name"));
            note = reader.GetString(reader.GetOrdinal("note"));
         }
        reader.Close();
    }
}